{include file="../Public/header.html"}
<script type="text/javascript" src="__PUBLIC__/Js/jquery.SetTableBgColor.js"></script>
<script type="text/javascript" src="__PUBLIC__/Js/dataList.js"></script>
<script type="text/javascript">
var g = '{$smarty.const.GROUP_NAME}';
var m = '{$smarty.const.MODULE_NAME}';
var _hash_ = '{$_hash_}';
<!--{literal}-->
function del(id)
{
	$('#dialog>p').html('将删除所有的优惠券及其他相关数据<br />确定要删除吗？');
	$('#dialog').dialog('open');
	$('#dialog').dialog({
					autoOpen: false,
					width: 300,
					buttons: {
						"确定": function() { 
							var url = "?g="+g+"&m="+m+"&a=del&id="+id+"&ajax=1&_hash_="+_hash_;
							$.getJSON(url, function(data){
													if(data.status == 0){
														$('#dialog>p').html('删除失败');
														$('#dialog').dialog('open');
													}else{
														$('#dialog').dialog('close');
														$('#tt-item-'+id).remove();
														_hash_ = data.info;
													}
													});
						},
						"取消": function() { 
							$(this).dialog("close"); 
						}
					}
				});
}
function single_action(action, isajax)
{
	if(check_count('id[]') == 0){
		$('#dialog>p').html('请选择商家');
		$('#dialog').dialog('open');
		return false;
	}
	if(check_count('id[]') > 1){
		$('#dialog>p').html('只能选择一个商家');
		$('#dialog').dialog('open');
		return false;
	}
	var id = get_check_val('id[]');
	var url = "?g="+g+"&m="+m+"&a="+action+"&id="+id;
	if(isajax === false){
		window.location.href = url;
	}
	url += "&ajax=1&_hash_="+_hash_;
	$.getJSON(url, function(data){
			if(data.status == 0){
				$('#dialog>p').html(data.info);
				$('#dialog').dialog('open');
			}else{
				$('#dialog>p').html('操作成功');
				if(action == 'rec2index'){
					_hash_ = data.info;
					$('#dialog').dialog('open');
				}else{
					window.location.href = document.URL;
				}
			}
	});
}
function active()
{
	$('#dialog>p').html('将重新激活该商家所有未过期的优惠券');
	$('#dialog').dialog('open');
	single_action('active');
}
function unactive()
{
	$('#dialog>p').html('将屏蔽该商家所有未过期的优惠券');
	$('#dialog').dialog('open');
	single_action('unactive');
}
function rec()
{
	single_action('rec', false);
}
function add_shop(form)
{
	if(form.nick.value == ''){
		$('#dialog>p').html('请输入商家昵称');
		$('#dialog').dialog('open');
		return false;
	}
	var url = "?g="+g+"&m="+m+"&a=add_step3&nick="+encodeURIComponent(form.nick.value)+"&ajax=1&_hash_="+_hash_;
	$.getJSON(url, function(data){
			if(data.status == 0){
				$('#dialog>p').html('添加失败');
				$('#dialog').dialog('open');
			}else{
				$('#dialog>p').html('添加成功');
				$('#dialog').dialog('open');
				window.location.href = document.URL;
			}
			_hash_ = data.info;
	});
	return false;
}
$(document).ready(function(){
	$(".table-list").SetTableBgColor({
            odd:"even",
            even:"",
            selected:"",
            over:""
        });
});
<!--{/literal}-->
</script>
<div class="handle-btns">
	<div class="img-button "><p><input type="button" class="addData" onclick="window.location.href='?g={$smarty.const.GROUP_NAME}&m={$smarty.const.MODULE_NAME}&a=add'" value="添加商家" name="addData" id="addData"></p></div>
    <div class="img-button "><p><input type="button" class="addData" onclick="active()" value="激活" name="addData" id="addData"></p></div>
    <div class="img-button "><p><input type="button" class="addData" onclick="unactive()" value="屏蔽" name="addData" id="addData"></p></div>
    <div class="img-button "><p><input type="button" class="addData" onclick="rec()" value="推荐" name="addData" id="addData"></p></div>
	</div>
<div class="search-box">
    <form action="?">
    	<span>分类</span>
        <select name="cid">
        <option value="0">不限...</option>
        <!--{foreach from=$category item=item key=key}-->
        <option value="{$item.cid}">{$item.prefix}{$item.name}</option>
        <!--{/foreach}-->
        </select>
        <span>关键字</span>
        <input type="text" size="12" name="kw" value="" class="textinput">
		<small></small>
		<input type="submit" value="搜索" class="submit_btn">
        <input type="hidden" value="{$smarty.const.GROUP_NAME}" name="g">
		<input type="hidden" value="{$smarty.const.MODULE_NAME}" name="m">
		<input type="hidden" value="{$smarty.const.ACTION_NAME}" name="a">
  </form>
</div>
<div class="search-box">
    <form action="?g={$smarty.const.GROUP_NAME}&m={$smarty.const.MODULE_NAME}&a={$smarty.const.ACTION_NAME}" onsubmit="return add_shop(this)">
        <span>商家昵称</span>
        <input type="text" size="12" name="nick" value="" class="textinput">
		<input type="submit" value="添加商家" class="submit_btn">
  </form>
</div>
<table cellspacing="0" cellpadding="0" border="0" class="table-list list" id="checkList">
<thead>
<tr>
<th width="30" class="first"><input type="checkbox" onclick="check_all('id[]', this)"></th>
<th>店铺名称</th>
<th>店铺掌柜</th>
<th>等级</th>
<th width="80">返现比率</th>
<th width="150">所在地</th>
<th width="50">好评率</th>
<th width="120">最后更新</th>
<th width="40">激活</th>
<th width="60">排序</th>
<th width="150">操作</th>
</tr>
</thead>
<tbody>
<!--{foreach from=$shops item=item}-->
<tr id="tt-item-{$item.id}">
<td class="first"><input type="checkbox" value="{$item.id}" name="id[]"></td>
<td align="left"><a href="?g={$smarty.const.GROUP_NAME}&m={$smarty.const.MODULE_NAME}&a=edit&id={$item.id}">{$item.title}</a></td>
<td align="left">{$item.nick}</td>
<td align="left"><img src="__PUBLIC__/Images/Taobao/level_{$item.level}.gif" /></td>
<td align="left">{$item.commission_rate} %</td>
<td align="center">{$item.state} - {$item.city}</td>
<td align="center">{$item.good} %</td>
<td align="center">{$item.updatetime}</td>
<td align="center"><img src="__PUBLIC__/Css/Admin/Images/status-{$item.is_active}.gif" class="status" status="{$item.is_active}" /></td>
<td align="center"><span class="pointer" module="{$smarty.const.MODULE_NAME}" group="{$smarty.const.GROUP_NAME}" model="" pk="" href="javascript:;" onclick="textEdit(this,'{$item.id}','sort_order')">{$item.sort_order}</span></td>
<td align="center"><a href="?g={$smarty.const.GROUP_NAME}&m=TaoCoupon&a=add&s_id={$item.id}">添加优惠券</a>&nbsp;&nbsp;<a href="?g={$smarty.const.GROUP_NAME}&m={$smarty.const.MODULE_NAME}&a=edit&id={$item.id}">编辑</a>
&nbsp;&nbsp;<a onclick="del({$item.id})" href="javascript:;">删除</a>
</td>
</tr>
<!--{/foreach}-->
</tbody></table>
<div class="pager">{$pagelink}</div>
{include file="../Public/footer.html"}